package team.sun.sss.service.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.sun.sss.dao.user.UserDao;
import team.sun.sss.pojo.user.User;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    UserDao userDao;

    @Override
    public int login(int userId, String userPwd) {
        User user = userDao.selectUserByIdAndPwd(userId, userPwd);
        if (user  == null) {
            return 0;
        }
        if (user.getUserState() == 1) {
            return 0;
        }
        return user.getUserType();
    }

    @Override
    public User getLoginInfo(int userId, String userPwd) {
        User user = userDao.selectUserByIdAndPwd(userId, userPwd);
        return user;
    }

    @Override
    public int userStop(String userId) {
        return userDao.userStop(userId);
    }

    @Override
    public int userStart(String userId)  {
        return userDao.userStart(userId);
    }
}
